package pcjavanet.mobilesell.web.action;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import pcjavanet.mobilesell.model.Purchase;
import pcjavanet.mobilesell.model.PageBean;
import pcjavanet.mobilesell.model.QryCondition;
import pcjavanet.mobilesell.service.PurchaseService;

import com.opensymphony.xwork2.ActionSupport;
@Namespace("/purchase")
@Controller
@Scope("prototype")
@ParentPackage("json-default")
@Results({
	@Result(name = "success", location = "/view/Purchase.jsp"),
	@Result(name = "input", location = "/view/Purchase.jsp")
})

public class PurchaseAction  extends ActionSupport {

  @Resource
  private PurchaseService purchaseService;
  private   java.lang.Integer dbid ;
  private   java.lang.String name ;
  private   java.lang.Integer refShopDbidshopDbid ;
  private   java.lang.Integer refColorDbid ;
  private   java.lang.Integer refConfigurationDbid ;
  private   java.lang.Integer refUnitDbid ;
  private   java.lang.Integer plannumber ;
  private   java.lang.Integer realnumber ;
  private   java.lang.Double planunitprice ;
  private   java.lang.Double planmoney ;
  private   java.lang.Double realunitprice ;
  private   java.lang.String memo ;
  private   java.util.Date createDate ;
  private int start  ;
  private int limit  ;
  private int totalProperty  ;
  private boolean success = true ;
  private String  info ;
  private List<Purchase>  purchasePageBeans  ;
  public    java.lang.Integer getDbid() {
   	return this.dbid;
  }
  public void setDbid(  java.lang.Integer  dbid) {
   	 this.dbid=dbid;
  }
  public    java.lang.String getName() {
   	return this.name;
  }
  public void setName(  java.lang.String  name) {
   	 this.name=name;
  }
  public    java.lang.Integer getRefShopDbidshopDbid() {
   	return this.refShopDbidshopDbid;
  }
  public void setRefShopDbidshopDbid(  java.lang.Integer  refShopDbidshopDbid) {
   	 this.refShopDbidshopDbid=refShopDbidshopDbid;
  }
  public    java.lang.Integer getRefColorDbid() {
   	return this.refColorDbid;
  }
  public void setRefColorDbid(  java.lang.Integer  refColorDbid) {
   	 this.refColorDbid=refColorDbid;
  }
  public    java.lang.Integer getRefConfigurationDbid() {
   	return this.refConfigurationDbid;
  }
  public void setRefConfigurationDbid(  java.lang.Integer  refConfigurationDbid) {
   	 this.refConfigurationDbid=refConfigurationDbid;
  }
  public    java.lang.Integer getRefUnitDbid() {
   	return this.refUnitDbid;
  }
  public void setRefUnitDbid(  java.lang.Integer  refUnitDbid) {
   	 this.refUnitDbid=refUnitDbid;
  }
  public    java.lang.Integer getPlannumber() {
   	return this.plannumber;
  }
  public void setPlannumber(  java.lang.Integer  plannumber) {
   	 this.plannumber=plannumber;
  }
  public    java.lang.Integer getRealnumber() {
   	return this.realnumber;
  }
  public void setRealnumber(  java.lang.Integer  realnumber) {
   	 this.realnumber=realnumber;
  }
  public    java.lang.Double getPlanunitprice() {
   	return this.planunitprice;
  }
  public void setPlanunitprice(  java.lang.Double  planunitprice) {
   	 this.planunitprice=planunitprice;
  }
  public    java.lang.Double getPlanmoney() {
   	return this.planmoney;
  }
  public void setPlanmoney(  java.lang.Double  planmoney) {
   	 this.planmoney=planmoney;
  }
  public    java.lang.Double getRealunitprice() {
   	return this.realunitprice;
  }
  public void setRealunitprice(  java.lang.Double  realunitprice) {
   	 this.realunitprice=realunitprice;
  }
  public    java.lang.String getMemo() {
   	return this.memo;
  }
  public void setMemo(  java.lang.String  memo) {
   	 this.memo=memo;
  }
  public    java.util.Date getCreateDate() {
   	return this.createDate;
  }
  public void setCreateDate(  java.util.Date  createDate) {
   	 this.createDate=createDate;
  }
  public  void setStart(int start) {
   	 this.start = start;
  }
  public  void setLimit(int limit) {
   	 this.limit = limit;
  }
  public  void setTotalProperty(int totalProperty) {
   	 this.totalProperty = totalProperty;
  }
  public  void setPurchasePageBeans(List<Purchase> purchasePageBeans){
   	 this.purchasePageBeans =purchasePageBeans  ;
  }
  public  int getStart( ) {
   	 return this.start;
  }
  public  int getLimit( ) {
   	 return this.limit;
  }
  public  int getTotalProperty( ) {
   	 return this.totalProperty;
  }
  public    List<Purchase> getPurchasePageBeans(){
   	 return this.purchasePageBeans   ;
  }
  public  String getInfo( ) {
   	 return this.info;
  }
  public  void setInfo(String info){
   	 this.info = info ;
  }
  public  boolean getSuccess( ) {
   	 return this.success;
  }
  public  void setSuccess(boolean success){
   	 this.success = success ;
  }

  @Action(value="insertPurchase",results = {@Result(name = "success", type = "json")})
  public String  insertPurchase() throws Exception{
   	success = false ;
   	info = "" ;
  	Purchase bean = new Purchase();
  	bean.setName(this.name); 
  	bean.setRefShopDbidshopDbid(this.refShopDbidshopDbid); 
  	bean.setRefColorDbid(this.refColorDbid); 
  	bean.setRefConfigurationDbid(this.refConfigurationDbid); 
  	bean.setRefUnitDbid(this.refUnitDbid); 
  	bean.setPlannumber(this.plannumber); 
  	bean.setRealnumber(this.realnumber); 
  	bean.setPlanunitprice(this.planunitprice); 
  	bean.setPlanmoney(this.planmoney); 
  	bean.setRealunitprice(this.realunitprice); 
  	bean.setMemo(this.memo); 
  	bean.setCreateDate(this.createDate); 
	purchaseService.insert(bean);
   	success = true ;
   	info = "Add Successful" ;
   	return SUCCESS;
  }

  @Action(value="queryPurchase",results = {@Result(name = "success", type = "json")})
  public String  queryPurchase() throws Exception{
  	Purchase bean = new Purchase();
  	bean.setDbid(this.dbid); 
  	bean.setName(this.name); 
  	bean.setRefShopDbidshopDbid(this.refShopDbidshopDbid); 
  	bean.setRefColorDbid(this.refColorDbid); 
  	bean.setRefConfigurationDbid(this.refConfigurationDbid); 
  	bean.setRefUnitDbid(this.refUnitDbid); 
  	bean.setPlannumber(this.plannumber); 
  	bean.setRealnumber(this.realnumber); 
  	bean.setPlanunitprice(this.planunitprice); 
  	bean.setPlanmoney(this.planmoney); 
  	bean.setRealunitprice(this.realunitprice); 
  	bean.setMemo(this.memo); 
  	bean.setCreateDate(this.createDate); 
	purchaseService.selectByPrimaryKey(bean);
   	return SUCCESS;
  }

  @Action(value="updatePurchase",results = {@Result(name = "success", type = "json")})
  public String  updatePurchase() throws Exception{
   	success = false ;
   	info = "" ;
  	Purchase bean = new Purchase();
  	bean.setDbid(this.dbid); 
  	bean.setName(this.name); 
  	bean.setRefShopDbidshopDbid(this.refShopDbidshopDbid); 
  	bean.setRefColorDbid(this.refColorDbid); 
  	bean.setRefConfigurationDbid(this.refConfigurationDbid); 
  	bean.setRefUnitDbid(this.refUnitDbid); 
  	bean.setPlannumber(this.plannumber); 
  	bean.setRealnumber(this.realnumber); 
  	bean.setPlanunitprice(this.planunitprice); 
  	bean.setPlanmoney(this.planmoney); 
  	bean.setRealunitprice(this.realunitprice); 
  	bean.setMemo(this.memo); 
  	bean.setCreateDate(this.createDate); 
  	bean =purchaseService.selectByPrimaryKey(bean);
  	bean.setDbid(this.dbid); 
  	bean.setName(this.name); 
  	bean.setRefShopDbidshopDbid(this.refShopDbidshopDbid); 
  	bean.setRefColorDbid(this.refColorDbid); 
  	bean.setRefConfigurationDbid(this.refConfigurationDbid); 
  	bean.setRefUnitDbid(this.refUnitDbid); 
  	bean.setPlannumber(this.plannumber); 
  	bean.setRealnumber(this.realnumber); 
  	bean.setPlanunitprice(this.planunitprice); 
  	bean.setPlanmoney(this.planmoney); 
  	bean.setRealunitprice(this.realunitprice); 
  	bean.setMemo(this.memo); 
  	bean.setCreateDate(this.createDate); 
	purchaseService.updateByPrimaryKeySelective(bean);
   	success = true ;
   	info = "Update Successful" ;
   	return SUCCESS;
  }

  @Action(value="deletePurchase",results = {@Result(name = "success", type = "json")})
  public String  deletePurchase() throws Exception{
  	Purchase bean = new Purchase();
  	bean.setDbid(this.dbid); 
  	bean.setName(this.name); 
  	bean.setRefShopDbidshopDbid(this.refShopDbidshopDbid); 
  	bean.setRefColorDbid(this.refColorDbid); 
  	bean.setRefConfigurationDbid(this.refConfigurationDbid); 
  	bean.setRefUnitDbid(this.refUnitDbid); 
  	bean.setPlannumber(this.plannumber); 
  	bean.setRealnumber(this.realnumber); 
  	bean.setPlanunitprice(this.planunitprice); 
  	bean.setPlanmoney(this.planmoney); 
  	bean.setRealunitprice(this.realunitprice); 
  	bean.setMemo(this.memo); 
  	bean.setCreateDate(this.createDate); 
	purchaseService.deleteByPrimaryKey(bean);
   	return SUCCESS;
  }

  @Action(value="listPurchase",results = {@Result(name = "success", type = "json")})
  public String  listPurchase() throws Exception{
 	QryCondition qry = RequestUtil.getQryCondition(   (javax.servlet.http.HttpServletRequest)com.opensymphony.xwork2.ActionContext.getContext().get(org.apache.struts2.ServletActionContext.HTTP_REQUEST)); 	PageBean pageBean = new PageBean();
	pageBean.setPageSize( limit );
	pageBean.setStartCount( start );
	totalProperty =purchaseService.getTotalRecords( qry, pageBean );
	purchasePageBeans =purchaseService.getOnePageBeans( qry, pageBean );
   	return SUCCESS;
  }

  @Action("index")
  public String index() throws Exception{
   	return SUCCESS;
  }

}
